home *** CD-ROM | disk | FTP | other *** search
/ FishMarket 1.0 / FishMarket v1.0.iso / fishies / 051-075 / disk_052 / tek4010 / menu.c < prev    next >
C/C++ Source or Header  |  1992-05-06  |  13KB  |  418 lines

  1. /***************************************************************
  2.  * vt100 - terminal emulator - initialization
  3.  *
  4.  *           860823 DBW - Integrated and rewrote lots of code
  5.  *      v2.0 860809 DBW - Major rewrite
  6.  *      v1.1 860720 DBW - Switches, 80 cols, colors, bug fixes
  7.  *      v1.0 860712 DBW - First version released
  8.  *
  9.  ***************************************************************/
  10.  
  11. #include "vt100.h"
  12. /* this file contains all the declarations for the menu items, it is
  13.    these structures are used only in the menu module */
  14.    
  15. #define TKMAX 3      /* screen menu items */
  16. struct MenuItem TKItem[TKMAX];
  17. struct IntuiText TKText[TKMAX];
  18.  
  19. #define PRMAX 2
  20. struct Menu  PRMenu;
  21. struct MenuItem PRItem[PRMAX];
  22. struct IntuiText PRText[PRMAX];
  23.  
  24. #define SCMAX 2
  25. struct Menu SCMenu;
  26. struct MenuItem SCItem[SCMAX];
  27. struct IntuiText SCText[SCMAX];  
  28.  
  29. /* this macro sets a command key sequence for a menu item */
  30. #define setseq(item, char) {\
  31.           item.Flags = item.Flags | COMMSEQ; \
  32.           item.Command = char;}
  33.  
  34. extern struct Window *TekWindow;
  35. extern char *malloc();
  36.  
  37. /*****************************************************************/
  38. /*    The following function initializes the structure arrays    */
  39. /*   needed to provide the File menu topic.                      */
  40. /*****************************************************************/
  41. void InitFileItems()
  42. {
  43. int n;
  44.  
  45. /* initialize each menu item and IntuiText with loop */
  46. for( n=0; n<FILEMAX; n++ )
  47.    {
  48.    FileItem[n].NextItem = &FileItem[n+1];
  49.    FileItem[n].LeftEdge = 0;
  50.    FileItem[n].TopEdge = 11 * n;
  51.    FileItem[n].Width = 200;
  52.    FileItem[n].Height = 11;
  53.    FileItem[n].Flags = ITEMTEXT | ITEMENABLED | HIGHCOMP;
  54.    FileItem[n].MutualExclude = 0;
  55.    FileItem[n].ItemFill = (APTR)&FileText[n];
  56.    FileItem[n].SelectFill = NULL;
  57.    FileItem[n].Command = 0;
  58.    FileItem[n].SubItem = NULL;
  59.    FileItem[n].NextSelect = 0;
  60.  
  61.    FileText[n].FrontPen = 0;
  62.    FileText[n].BackPen = 1;
  63.    FileText[n].DrawMode = JAM2;     /* render in fore and background */
  64.    FileText[n].LeftEdge = 0;
  65.    FileText[n].TopEdge = 1;
  66.    FileText[n].ITextFont = NULL;
  67.    FileText[n].NextText = NULL;
  68.    }
  69. FileItem[FILEMAX-1].NextItem = NULL;
  70.  
  71. /* initialize text for specific menu items */
  72. FileText[0].IText = (UBYTE *)"Ascii Capture";
  73. FileText[1].IText = (UBYTE *)"Ascii Send";
  74. FileText[2].IText = (UBYTE *)"Xmodem Receive";
  75. FileText[3].IText = (UBYTE *)"Xmodem Send";
  76. FileText[4].IText = (UBYTE *)"Kermit Get";
  77. setseq(FileItem[4], 'G');
  78. FileText[5].IText = (UBYTE *)"Kermit Receive";
  79. setseq(FileItem[5], 'R');
  80. FileText[6].IText = (UBYTE *)"Kermit Send";
  81. setseq(FileItem[6], 'S');
  82. FileText[7].IText = (UBYTE *)"Kermit BYE";
  83. setseq(FileItem[7], 'B');
  84. }
  85.  
  86. /*****************************************************************/
  87. /*    The following function initializes the structure arrays    */
  88. /*   needed to provide the BaudRate menu topic.                  */
  89. /*****************************************************************/
  90. void InitRSItems()
  91. {
  92. int n;
  93.  
  94. /* initialize each menu item and IntuiText with loop */
  95. for( n=0; n<RSMAX; n++ )
  96.    {
  97.    RSItem[n].NextItem = &RSItem[n+1];
  98.    RSItem[n].LeftEdge = 0;
  99.    RSItem[n].TopEdge = 11 * n;
  100.    RSItem[n].Width = 65;
  101.    RSItem[n].Height = 11;
  102.    RSItem[n].Flags = ITEMTEXT | ITEMENABLED | HIGHCOMP | CHECKIT;
  103.    RSItem[n].MutualExclude = (~(1 << n));
  104.    RSItem[n].ItemFill = (APTR)&RSText[n];
  105.    RSItem[n].SelectFill = NULL;
  106.    RSItem[n].Command = 0;
  107.    RSItem[n].SubItem = NULL;
  108.    RSItem[n].NextSelect = 0;
  109.  
  110.    RSText[n].FrontPen = 0;
  111.    RSText[n].BackPen = 1;
  112.    RSText[n].DrawMode = JAM2;     /* render in fore and background */
  113.    RSText[n].LeftEdge = 0;
  114.    RSText[n].TopEdge = 1;
  115.    RSText[n].ITextFont = NULL;
  116.    RSText[n].NextText = NULL;
  117.    }
  118. RSItem[RSMAX-1].NextItem = NULL;
  119. /* select baud item chekced */
  120. n = -1;
  121. switch (p_baud) {
  122.     case 300:   n = 0; break;
  123.     case 1200:  n = 1; break;
  124.     case 2400:  n = 2; break;
  125.     case 4800:  n = 3; break;
  126.     case 9600:  n = 4; break;
  127.     case 19200: n = 5; break;
  128.     }
  129. if (n != -1) RSItem[n].Flags = 
  130.                ITEMTEXT | ITEMENABLED | HIGHCOMP | CHECKIT | CHECKED;
  131.  
  132. /* initialize text for specific menu items */
  133. RSText[0].IText = (UBYTE *)"   300";
  134. RSText[1].IText = (UBYTE *)"   1200";
  135. RSText[2].IText = (UBYTE *)"   2400";
  136. RSText[3].IText = (UBYTE *)"   4800";
  137. RSText[4].IText = (UBYTE *)"   9600";
  138. RSText[5].IText = (UBYTE *)"  19200";
  139. }
  140.  
  141. /*****************************************************************/
  142. /*    The following function initializes the structure arrays    */
  143. /*    needed to provide the Transfer Mode menu topic.            */
  144. /*****************************************************************/
  145. void InitXFItems()
  146. {
  147. int n;
  148.  
  149. /* initialize each menu item and IntuiText with loop */
  150. for( n=0; n<XFMAX; n++ )
  151.    {
  152.    XFItem[n].NextItem = &XFItem[n+1];
  153.    XFItem[n].LeftEdge = 0;
  154.    XFItem[n].TopEdge = 11 * n;
  155.    XFItem[n].Width = 85;
  156.    XFItem[n].Height = 11;
  157.    XFItem[n].Flags = ITEMTEXT | ITEMENABLED | HIGHCOMP | CHECKIT;
  158.    XFItem[n].MutualExclude = (~(1 << n));
  159.    XFItem[n].ItemFill = (APTR)&XFText[n];
  160.    XFItem[n].SelectFill = NULL;
  161.    XFItem[n].Command = 0;
  162.    XFItem[n].SubItem = NULL;
  163.    XFItem[n].NextSelect = 0;
  164.  
  165.    XFText[n].FrontPen = 0;
  166.    XFText[n].BackPen = 1;
  167.    XFText[n].DrawMode = JAM2;     /* render in fore and background */
  168.    XFText[n].LeftEdge = 0;
  169.    XFText[n].TopEdge = 1;
  170.    XFText[n].ITextFont = NULL;
  171.    XFText[n].NextText = NULL;
  172.    }
  173. XFItem[XFMAX-1].NextItem = NULL;
  174. /* mode checked */
  175. XFItem[p_mode].Flags = ITEMTEXT | ITEMENABLED | HIGHCOMP | CHECKIT | CHECKED;
  176.  
  177. /* initialize text for specific menu items */
  178. XFText[0].IText = (UBYTE *)"  image";
  179. XFText[1].IText = (UBYTE *)"  CR LF";
  180. }
  181.  
  182.  
  183. /*****************************************************************/
  184. /*    The following function initializes the structure arrays    */
  185. /*   needed to provide the Script menu topic.                    */
  186. /*****************************************************************/
  187. void InitScriptItems()
  188. {
  189. int n;
  190.  
  191. /* initialize each menu item and IntuiText with loop */
  192. for( n=0; n<SCRIPTMAX; n++ )
  193.    {
  194.    ScriptItem[n].NextItem = &ScriptItem[n+1];
  195.    ScriptItem[n].LeftEdge = 0;
  196.    ScriptItem[n].TopEdge = 11 * n;
  197.    ScriptItem[n].Width = 170;
  198.    ScriptItem[n].Height = 11;
  199.    ScriptItem[n].Flags = ITEMTEXT | ITEMENABLED | HIGHCOMP;
  200.    ScriptItem[n].MutualExclude = 0;
  201.    ScriptItem[n].ItemFill = (APTR)&ScriptText[n];
  202.    ScriptItem[n].SelectFill = NULL;
  203.    ScriptItem[n].SubItem = NULL;
  204.    ScriptItem[n].NextSelect = 0;
  205.  
  206.    ScriptText[n].FrontPen = 0;
  207.    ScriptText[n].BackPen = 1;
  208.    ScriptText[n].DrawMode = JAM2;     /* render in fore and background */
  209.    ScriptText[n].LeftEdge = 0;
  210.    ScriptText[n].TopEdge = 1;
  211.    ScriptText[n].ITextFont = NULL;
  212.    ScriptText[n].NextText = NULL;
  213.    }
  214. ScriptItem[SCRIPTMAX-1].NextItem = NULL;
  215.  
  216. /* initialize text for specific menu items */
  217. ScriptText[0].IText = (UBYTE *)"Execute file";
  218. setseq(ScriptItem[0], 'F');
  219. ScriptText[1].IText = (UBYTE *)"Abort Execution";
  220. setseq(ScriptItem[1],  'E');
  221. }
  222. /*****************************************************************/
  223. /*    The following function initializes the structure arrays    */
  224. /*    needed to provide the  Screen  menu topic.                 */
  225. /*****************************************************************/
  226. void InitTEKItems()
  227. {
  228. int n;
  229.  
  230. /* initialize each menu item and IntuiText with loop */
  231. for( n=0; n<TKMAX; n++ )
  232.    {
  233.    TKItem[n].NextItem = &TKItem[n+1];
  234.    TKItem[n].LeftEdge = 0;
  235.    TKItem[n].TopEdge = 11 * n;
  236.    TKItem[n].Width = 140;
  237.    TKItem[n].Height = 11;
  238.    TKItem[n].Flags = ITEMTEXT | ITEMENABLED | HIGHCOMP;
  239.    TKItem[n].MutualExclude = 0;
  240.    TKItem[n].ItemFill = (APTR)&TKText[n];
  241.    TKItem[n].SelectFill = NULL;
  242.    TKItem[n].SubItem = NULL;
  243.    TKItem[n].NextSelect = 0;
  244.  
  245.    TKText[n].FrontPen = 0;
  246.    TKText[n].BackPen = 1;
  247.    TKText[n].DrawMode = JAM2;     /* render in fore and background */
  248.    TKText[n].LeftEdge = 0;
  249.    TKText[n].TopEdge = 1;
  250.    TKText[n].ITextFont = NULL;
  251.    TKText[n].NextText = NULL;
  252.    }
  253. TKItem[TKMAX-1].NextItem = NULL;
  254.  
  255. /* initialize text for specific menu items */
  256. TKText[0].IText = (UBYTE *)"   VT100";
  257. setseq(TKItem[0], 'V');
  258. TKText[1].IText = (UBYTE *)"TEK 4010";
  259. setseq(TKItem[1], 'T');
  260. TKText[2].IText = (UBYTE *)"   Clear";
  261. setseq(TKItem[2], 'C');
  262. }
  263.  
  264. /**********************************************************************/
  265. /*   The following function initializes the Menu structure array with */
  266. /*  appropriate values for our simple menu strip.  Review the manual  */
  267. /*  if you need to know what each value means.                        */
  268. /**********************************************************************/
  269. void InitMenu()
  270. {
  271. InitFileItems();
  272. menu[0].NextMenu = &menu[1];
  273. menu[0].LeftEdge = 340;
  274. menu[0].TopEdge = 0;
  275. menu[0].Width = 100;
  276. menu[0].Height = 10;
  277. menu[0].Flags = MENUENABLED;
  278. menu[0].MenuName = "File";           /* text for menu-bar display */
  279. menu[0].FirstItem = &FileItem[0];    /* pointer to first item in list */
  280.  
  281. InitRSItems();
  282. menu[1].NextMenu = &menu[2];
  283. menu[1].LeftEdge = 0;
  284. menu[1].TopEdge = 0;
  285. menu[1].Width = 70;
  286. menu[1].Height = 10;
  287. menu[1].Flags = MENUENABLED;
  288. menu[1].MenuName = " Baud";        /* text for menu-bar display */
  289. menu[1].FirstItem = &RSItem[0];    /* pointer to first item in list */
  290.  
  291. InitXFItems();
  292. menu[2].NextMenu = &menu[3];
  293. menu[2].LeftEdge = 240;
  294. menu[2].TopEdge = 0;
  295. menu[2].Width = 100;
  296. menu[2].Height = 10;
  297. menu[2].Flags = MENUENABLED;
  298. menu[2].MenuName = "Xfer Mode";        /* text for menu-bar display */
  299. menu[2].FirstItem = &XFItem[0];    /* pointer to first item in list */
  300.  
  301. InitScriptItems();
  302. menu[3].NextMenu = &menu[4];
  303. menu[3].LeftEdge = 440;
  304. menu[3].TopEdge = 0;
  305. menu[3].Width = 100;
  306. menu[3].Height = 10;
  307. menu[3].Flags = MENUENABLED;
  308. menu[3].MenuName = "Script";        /* text for menu-bar display */
  309. menu[3].FirstItem = &ScriptItem[0];    /* pointer to first item in list */
  310.  
  311. InitTEKItems();
  312. menu[4].NextMenu = &PRMenu;
  313. menu[4].LeftEdge = 140;
  314. menu[4].TopEdge = 0;
  315. menu[4].Width = 100;
  316. menu[4].Height = 10;
  317. menu[4].Flags = MENUENABLED;
  318. menu[4].MenuName = "Screen";        /* text for menu-bar display */
  319. menu[4].FirstItem = &TKItem[0];    /* pointer to first item in list */
  320.  
  321. InitMore();
  322.  
  323. SetMenuStrip(mywindow,&menu[0]);
  324. SetMenuStrip(TekWindow,&menu[0]);
  325. }
  326.  
  327.  
  328. /*****************************************************/
  329. /*                  Menu Construction                */
  330. /*****************************************************/
  331. InitMore()
  332. {  
  333. register int n;
  334.  
  335. /* initialize the Misc. menu */
  336. PRMenu.NextMenu  = &SCMenu;
  337. PRMenu.LeftEdge = 540;
  338. PRMenu.TopEdge = 0;
  339. PRMenu.Width = 90;
  340. PRMenu.Height = 10;
  341. PRMenu.Flags = MENUENABLED;
  342. PRMenu.MenuName = "Misc.";
  343. PRMenu.FirstItem = &PRItem[0];
  344.  
  345.   
  346. /* initialize each menu item and IntuiText with loop */
  347. for( n=0; n<PRMAX; n++ )
  348.    {
  349.    PRItem[n].NextItem = &PRItem[n+1];
  350.    PRItem[n].LeftEdge = -50;
  351.    PRItem[n].TopEdge = 11 * n;
  352.    PRItem[n].Width = 140;
  353.    PRItem[n].Height = 11;
  354.    PRItem[n].Flags = ITEMTEXT|ITEMENABLED|HIGHCOMP;
  355.    PRItem[n].MutualExclude = 0;
  356.    PRItem[n].ItemFill = (APTR)&PRText[n];
  357.    PRItem[n].SelectFill = NULL;
  358.    PRItem[n].Command = 0;
  359.    PRItem[n].SubItem = NULL;
  360.    PRItem[n].NextSelect = 0;
  361.   
  362.    PRText[n].FrontPen = 0;
  363.    PRText[n].BackPen = 1;
  364.    PRText[n].DrawMode = JAM2;     /* render in fore and background */
  365.    PRText[n].LeftEdge = 0;
  366.    PRText[n].TopEdge = 1;
  367.    PRText[n].ITextFont = NULL;
  368.    PRText[n].NextText = NULL;
  369.    }
  370.    PRItem[PRMAX-1].NextItem = NULL;
  371.  
  372.   /* initialize text for specific menu items */
  373. PRText[0].IText = (UBYTE *) " Quit";
  374. setseq(PRItem[0], 'Q');
  375. PRText[1].IText = (UBYTE *) "About"; 
  376.  
  377. SCMenu.NextMenu = NULL;
  378. SCMenu.LeftEdge = 70;
  379. SCMenu.TopEdge = 0;
  380. SCMenu.Width = 70;
  381. SCMenu.Height = 10;
  382. SCMenu.Flags = MENUENABLED;
  383. SCMenu.MenuName = "Scale";
  384. SCMenu.FirstItem = &SCItem[0];
  385.   
  386. /* initialize each menu item and IntuiText with loop */
  387. for( n=0; n<SCMAX; n++ )
  388.    {
  389.    SCItem[n].NextItem = &SCItem[n+1];
  390.    SCItem[n].LeftEdge = 0;
  391.    SCItem[n].TopEdge = 11 * n;
  392.    SCItem[n].Width = 85;
  393.    SCItem[n].Height = 11;
  394.    SCItem[n].Flags = ITEMTEXT | ITEMENABLED | HIGHCOMP | CHECKIT;
  395.    SCItem[n].MutualExclude = 0xFFFF - (1<<n);
  396.    SCItem[n].ItemFill = (APTR)&SCText[n];
  397.    SCItem[n].SelectFill = NULL;
  398.    SCItem[n].Command = 0;
  399.    SCItem[n].SubItem = NULL;
  400.    SCItem[n].NextSelect = 0;
  401.   
  402.    SCText[n].FrontPen = 0;
  403.    SCText[n].BackPen = 1;
  404.    SCText[n].DrawMode = JAM2;     /* render in fore and background */
  405.    SCText[n].LeftEdge = 0;
  406.    SCText[n].TopEdge = 1;
  407.    SCText[n].ITextFont = NULL;
  408.    SCText[n].NextText = NULL;
  409.    }
  410. SCItem[SCMAX-1].NextItem = NULL;
  411.  
  412.   
  413. /* initialize text for specific menu items */
  414. SCText[0].IText = (UBYTE *)"  1024x780";
  415. SCText[1].IText = (UBYTE *)"   640x400";
  416. SCItem[TekScale].Flags = SCItem[0].Flags | CHECKED;
  417. }
  418.